package com.qfedu.springmvc02.response;

import com.sun.xml.internal.bind.v2.TODO;

public class Response<T> {
    private Integer code;
    private String msg;
    private T data;


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
    public Response(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> Response<T> success(Integer code,String msg,T data){
        return new Response<>(code,msg,data);
    }
    public static <T> Response<T> success(T data){
        return success(0,"成功",data);
    }
    public static <T> Response<T> success(){
        return success(null);
    }

    public static <T> Response<T> fail(Integer code,String msg,T data){
        return new Response<>(code,msg,data);
    }
    public static <T> Response<T> fail(T data){
        return fail(-1,"失败",data);
    }

    public static <T> Response<T> fail(){
        return fail(null);
    }

}
